<template>
    <div class="app-container">
        <el-card>
            <!-- 搜索 -->
            <el-row :gutter="40">
                <el-col :span="6">
                    <el-input
                        placeholder="请输入内容"
                        clearable
                    >
                        <el-button
                            slot="append"
                            icon="el-icon-search"
                            >
                        </el-button>
                    </el-input>
                </el-col>
            </el-row>
            <!-- 列表 -->
            <el-table
                style="width: 100%"
                highlight-current-row
                border
                size="small"
                :data="userList"
                >
                <el-table-column
                    prop="id"
                    align="center"
                    label="用户ID">
                </el-table-column>
                <el-table-column
                    prop="name"
                    align="center"
                    label="登录名">
                </el-table-column>
                <el-table-column
                    prop="real_name"
                    align="center"
                    label="真实名">
                </el-table-column>
                <el-table-column align="center" label="操作" width="200px">
                    <template>
                        <el-button
                        type="primary"
                        icon="el-icon-edit"
                        size="mini"
                        >编辑</el-button>
                        <el-button
                        type="danger"
                        icon="el-icon-delete"
                        size="mini"
                        >删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script>
import { getUser } from '@/api/building'
    export default {
        name: 'userList',
        data() {
            return {
                userList: [],
                listQuery: {
                    page: 1,
                    page_size: 20,
                },
                addForm: {
                    id: '',
                    name: '',
                    real_name: ''
                },
            }
        },
        created() {
            this.getUserList();
        },
        methods: {
            //获取用户列表数据
            getUserList() {
                getUser(this.listQuery).then(res=>{
                    console.log(res);
                    if(res) {
                        this.userList = res;
                        //this.total = res.length;
                    }
                }).catch(err=>{
                    console.log(err.message)
                })
            },
        }
    }
</script>

<style lang="scss" scoped>

</style>